
@echo off

if     "%1" == "clean" goto clean
if     "%1" == "slk" goto slk 
if     "%1" == "lr" goto lr
if     "%1" == "comp" goto comp
if     "%1" == "help" goto usage
if     "%1" == "" goto usage

:slk
%SLK%slk %2 %3 %4 %5 -js calc.ll > slk.out
sed -e "/#include SlkExecute.txt/ r SlkExecute.txt" action.js > SlkAction.js
goto comp

:lr
%SLK%slk %2 %3 %4 %5 -js -LR calc.lr > slk.out
sed -e "/#include SlkExecute.txt/ r SlkExecute.txt" action.js > SlkAction.js

:comp
cat SlkConstants.js SlkString.js Stack.js Scanner.js SlkError.js SlkTree.js SlkAction.js SlkParser.js Calc.js > calc

goto exit

:clean
        @rm -f calc
	@rm -f *.obj
        @rm -f *.out
	@rm -f *.lst
        @rm -f *.err
	@rm -f *.map
        @rm -f *.def
        @rm -f *.exe
        @rm -f *.class
        @rm -f SlkKeywords.txt
        @rm -f SlkExecute.txt
        @rm -f SlkAction.*
        @rm -f SlkString.*
        @rm -f SlkConstants.*
        @rm -f SlkParser.*
        @rm -f SlkState.*        
	@rm -f xxx*

goto exit

:usage
echo Usage:  mak [clean] [help] [comp] [slk] [lr] [flags]
echo         node calc     to run the program

:exit
